/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  cn.hutool.core.util.StrUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.AnchorPane
 *  javafx.stage.Modality
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.salesReceipts;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.SalesReceiptsUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.CacheUtil;
import com.gys.common.util.CommonUtil;
import com.gys.common.util.ConstUtil;
import com.gys.common.util.ValidationUtil;
import com.gys.controller.BaseController;
import com.gys.controller.index.IndexController;
import com.gys.controller.salesReceipts.ApproveChangeRateController;
import com.gys.controller.salesReceipts.SalesReceiptsMainController;
import com.gys.data.example.GetLoginStoreOutData;
import com.gys.view.salesReceipts.ApproveChangeRateView;
import de.felixroske.jfxsupport.FXMLController;
import java.math.BigDecimal;
import java.net.URL;
import java.util.HashMap;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class SingleChangeRateController
extends BaseController
implements Initializable {
    private final int pageSize = ConstUtil.DEFAULT_PAGESIZE;
    private final int defaultPageCount = ConstUtil.DEFAULT_PAGECOUNT;
    @FXML
    private AnchorPane pane;
    @FXML
    private TextField rate;
    @Autowired
    private IndexController indexController;
    @Autowired
    private SalesReceiptsMainController salesReceiptsMainController;
    @Autowired
    private ApproveChangeRateController approveChangeRateController;
    private String changeRate;

    public void initialize(URL location, ResourceBundle resources) {
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        this.rate.setText("");
    }

    @FXML
    private void changeRate() {
        this.changeRate = this.rate.getText();
        if (StrUtil.isBlank((CharSequence)this.changeRate) || !ValidationUtil.checkPositiveInteger(this.changeRate)) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u6298\u7387\u5fc5\u987b\u4e3a\u6b63\u6574\u6570\uff01");
            alert.showAndWait();
            return;
        }
        HashMap<String, Object> param = new HashMap<String, Object>();
        param.put("prcStore", ((GetLoginStoreOutData)CacheUtil.get("store")).getStoCode());
        HttpJson rsp = SalesReceiptsUtil.getStoreDiscount(param);
        if (rsp.isSuccess()) {
            String discount = (String)JSON.parseObject((String)rsp.getMsg(), String.class);
            if (new BigDecimal(this.changeRate).compareTo(new BigDecimal(discount)) < 0) {
                this.approveChangeRateController.init();
                CommonUtil.showView(ApproveChangeRateView.class, Modality.APPLICATION_MODAL);
            } else {
                this.salesReceiptsMainController.singleChangeRateDo(this.changeRate);
                this.pane.getScene().getWindow().hide();
            }
        } else {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
            return;
        }
    }

    @FXML
    public void closeWindows() {
        this.pane.getScene().getWindow().hide();
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getDefaultPageCount() {
        return this.defaultPageCount;
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public TextField getRate() {
        return this.rate;
    }

    public IndexController getIndexController() {
        return this.indexController;
    }

    public SalesReceiptsMainController getSalesReceiptsMainController() {
        return this.salesReceiptsMainController;
    }

    public ApproveChangeRateController getApproveChangeRateController() {
        return this.approveChangeRateController;
    }

    public String getChangeRate() {
        return this.changeRate;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setRate(TextField rate) {
        this.rate = rate;
    }

    public void setIndexController(IndexController indexController) {
        this.indexController = indexController;
    }

    public void setSalesReceiptsMainController(SalesReceiptsMainController salesReceiptsMainController) {
        this.salesReceiptsMainController = salesReceiptsMainController;
    }

    public void setApproveChangeRateController(ApproveChangeRateController approveChangeRateController) {
        this.approveChangeRateController = approveChangeRateController;
    }

    public void setChangeRate(String changeRate) {
        this.changeRate = changeRate;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof SingleChangeRateController)) {
            return false;
        }
        SingleChangeRateController other = (SingleChangeRateController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (this.getPageSize() != other.getPageSize()) {
            return false;
        }
        if (this.getDefaultPageCount() != other.getDefaultPageCount()) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        TextField this$rate = this.getRate();
        TextField other$rate = other.getRate();
        if (this$rate == null ? other$rate != null : !this$rate.equals(other$rate)) {
            return false;
        }
        IndexController this$indexController = this.getIndexController();
        IndexController other$indexController = other.getIndexController();
        if (this$indexController == null ? other$indexController != null : !(this$indexController).equals(other$indexController)) {
            return false;
        }
        SalesReceiptsMainController this$salesReceiptsMainController = this.getSalesReceiptsMainController();
        SalesReceiptsMainController other$salesReceiptsMainController = other.getSalesReceiptsMainController();
        if (this$salesReceiptsMainController == null ? other$salesReceiptsMainController != null : !(this$salesReceiptsMainController).equals(other$salesReceiptsMainController)) {
            return false;
        }
        ApproveChangeRateController this$approveChangeRateController = this.getApproveChangeRateController();
        ApproveChangeRateController other$approveChangeRateController = other.getApproveChangeRateController();
        if (this$approveChangeRateController == null ? other$approveChangeRateController != null : !(this$approveChangeRateController).equals(other$approveChangeRateController)) {
            return false;
        }
        String this$changeRate = this.getChangeRate();
        String other$changeRate = other.getChangeRate();
        return !(this$changeRate == null ? other$changeRate != null : !this$changeRate.equals(other$changeRate));
    }

    protected boolean canEqual(Object other) {
        return other instanceof SingleChangeRateController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        result = result * 59 + this.getPageSize();
        result = result * 59 + this.getDefaultPageCount();
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        TextField $rate = this.getRate();
        result = result * 59 + ($rate == null ? 43 : $rate.hashCode());
        IndexController $indexController = this.getIndexController();
        result = result * 59 + ($indexController == null ? 43 : ($indexController).hashCode());
        SalesReceiptsMainController $salesReceiptsMainController = this.getSalesReceiptsMainController();
        result = result * 59 + ($salesReceiptsMainController == null ? 43 : ($salesReceiptsMainController).hashCode());
        ApproveChangeRateController $approveChangeRateController = this.getApproveChangeRateController();
        result = result * 59 + ($approveChangeRateController == null ? 43 : ($approveChangeRateController).hashCode());
        String $changeRate = this.getChangeRate();
        result = result * 59 + ($changeRate == null ? 43 : $changeRate.hashCode());
        return result;
    }

    public String toString() {
        return "SingleChangeRateController(pageSize=" + this.getPageSize() + ", defaultPageCount=" + this.getDefaultPageCount() + ", pane=" + this.getPane() + ", rate=" + this.getRate() + ", indexController=" + this.getIndexController() + ", salesReceiptsMainController=" + this.getSalesReceiptsMainController() + ", approveChangeRateController=" + this.getApproveChangeRateController() + ", changeRate=" + this.getChangeRate() + ")";
    }
}

